package ITA.MQproject;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;

public class TestPudProducer {

	public static void main(String[] args) throws JMSException {
		// TODO Auto-generated method stub
		ConnectionFactory factory=new ActiveMQConnectionFactory("tcp://10.222.29.152:61616");
		Destination queueDestination=new ActiveMQTopic("angers");
		Connection connection =factory.createConnection();
		connection.start();
		
		//false发送端认为每一条消息为一条事务，若为true则全部为异常事物
		Session session=connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		MessageProducer mp=session.createProducer(queueDestination);
		TextMessage msg=session.createTextMessage("hello i am angers");
		mp.send(msg);
		while(true){
			
		}
//		mp.close();
//		connection.close();
//		session.close();
	}

}
